define("pages/jls_sj/formjkjc", [
        '../../pages/jls_sj/formjkjc.html.js',
        "../../common/componts",
    ],
    function(require){
        var comonts=require("../../common/componts");
        comonts.initSelectPage(undefined);
        comonts.initSelect(undefined,undefined,undefined);
        var _show=function(_jbxx,_jkjc,refresh){
            var tmp= require("../../pages/jls_sj/formjkjc.html");
            var comonts = require("../../common/componts");
            var htmlcompile = template.compile(tmp);
           /* var _jcrs=loginuser.username;//获取当前办理人*/
            if(_jkjc.id!=undefined){
                _jcrs=_jkjc.jcrs;
            }
            var html = htmlcompile(
                {
                    jbxx:_jbxx,
                    /*jcrs:_jcrs,*/
                    data:_jkjc
                });
            $("#dlg").dialog('destroy')  //使用destroy来销毁dialog
            $("#jkjcdialog").html(html);  //取出id为jkjcdialog元素的内容
            $.parser.parse($("#jkjcdialog"));  //动态渲染
            //初始化下拉框
            comonts.initSelectPage(undefined);
            comonts.initSelect(undefined,undefined,undefined);
            //健康检查
            $("#tmtzA").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tmtzA").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tmtza').checked;
                    document.getElementById('tmtza').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tmtzA").show();
                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tmtza]:checkbox").attr("checked", false);
                    $("#Menu_tmtzA").hide();
                }
            });
            $("#tmtzB").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tmtzB").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tmtzb').checked;
                    document.getElementById('tmtzb').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tmtzB").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tmtzb]:checkbox").attr("checked", false);
                    $("#Menu_tmtzB").hide();
                }
            });
            $("#tmtzC").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tmtzC").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tmtzc').checked;
                    document.getElementById('tmtzc').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tmtzC").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tmtzc]:checkbox").attr("checked", false);
                    $("#Menu_tmtzC").hide();
                }
            });
            $("#tmtzD").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tmtzD").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tmtzd').checked;
                    document.getElementById('tmtzd').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tmtzD").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tmtzd]:checkbox").attr("checked", false);
                    $("#Menu_tmtzD").hide();
                }
            });
            $("#tmtzE").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tmtzE").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tmtze').checked;
                    document.getElementById('tmtze').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tmtzE").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tmtze]:checkbox").attr("checked", false);
                    $("#Menu_tmtzE").hide();
                }
            });
            $("#Menu_tmtzA").hide();
            $("#Menu_tmtzB").hide();
            $("#Menu_tmtzC").hide();
            $("#Menu_tmtzD").hide();
            $("#Menu_tmtzE").hide();
            //体表伤情
            $("#tbsq").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tbsq").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tbsqY').checked;
                    document.getElementById('tbsqY').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tbsq").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tbsqY]:checkbox").attr("checked", false);
                    $("#Menu_tbsq").hide();
                }
            });
            $("#Menu_tbsq").hide();
            //特殊检查项目
            $("#tsjcxm").bind("click",function(event){
                event.stopPropagation(); // 阻止向上冒泡
                if($("#Menu_tsjc").is(":hidden")){
                    //获取checked值并且默认选中=true显示div
                    var yy = document.getElementById('tsjc').checked;
                    document.getElementById('tsjc').checked=true;
                    //$("[name = ysh]:checkbox").attr("checked", true);
                    //当选中的时候
                    $("#Menu_tsjc").show();

                }else{
                    //checked值选中=false并且隐藏div
                    $("[name = tsjc]:checkbox").attr("checked", false);
                    $("#Menu_tsjc").hide();
                }
            });
            $("#Menu_tsjc").hide();
            var date = new Date();
            var str = date.getFullYear()+"-"+(date.getMonth()+1)+"-"+date.getDate();
            $('#jcrqfm').datebox('setValue', str);
            $("#xzzkfm").textbox("setValue", "良好");
            $("#yyfm").textbox("setValue", "良好");
            $("#gmsfm").textbox("setValue", "无");
            $("#zsbwfm").textbox("setValue", "无明显可见伤情");
            $('#gcbhfm').next().find('input[type=text]').css('background-color', '#EBEBE4');
            $('#xmfm').next().find('input[type=text]').css('background-color', '#EBEBE4');
            /*comboinputEvent();*/
            $('#dlg').window('open');
            bindAction(refresh);//refresh刷新
        }
        //健康检查form提交表单（保存操作） 接收
        var addjkjcForm=function(){
            var url = "/kss_jkjc/firstJkjc?sfyjs=1";
            var row = $('#jkjcId').datagrid('getSelected');
            var validate=$("#dlg").form('validate');
            var types = document.getElementById('cqcsfm').value;


            var gcbh = row.gcbh;
            if (validate) {
                $('#jsbhIDU').textbox('setValue',row.jsbh);
                var data =$("#fm_jkjc").serialize()+"&rybh="+row.rybh;
                /* ---- 验证身高  -----*/
                var num = document.getElementById('sgfm').value;
                if(!(/^6[0-9]$|^[6-9]\d$|^1\d{2}$|^2\d{2}$|^3\d{2}$/.test(num))){ //大于60小于400
                    $.messager.alert("提示","身高输入项的最小值是 60","info");
                    return false;
                }
                /* ---- 验证身高  -----*/
                /* ---- 验证体重  -----*/
                var num = document.getElementById('tzfm').value;
                if(!(/^3[0-9]$|^[2-9]\d$|^1\d{2}$|^2\d{2}$|^9\d{2}$/.test(num))){
                    $.messager.alert("提示","体重输入项的最小值是 30","info");
                    return false;
                }
                /* ---- 验证体重  -----*/
                /* ---- 验证足长  -----*/
                var num = document.getElementById('zcfm').value;
                if(!(/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^2\d{2}$|^9\d{2}$/.test(num))){
                    $.messager.alert("提示","足长输入项的最小值是 10","info");
                    return false;
                }
                /* ---- 验证足长  -----*/
                submitLoad();
                $.ajax({
                    type : "POST",  //提交方式
                    url : url,//路径
                    data :data,
                    success : function(result) {
                        if (result.success) {
                            $("#jkjcId").datagrid('load',{
                                "processDefinitionKey":getUrlParam('processDefinitionKey'),
                                "taskDefinitionKey":getUrlParam('taskDefinitionKey'),
                            });
                            removeLoad();
                            javascript:$('#dlg').dialog('close');
                            $.messager.alert("确定","保存成功","info");
                        }else{
                            removeLoad();
                            $.messager.alert("确定","保存失败","info");

                        }
                    },
                    complete:function(){
                        removeLoad();
                    },
                });
            }else{
                $.messager.alert("提示", '必填项不能为空！');
            }
        };

        //打印健康检查
        var print = function(gcbh){
            var labName="kss_jkjcdj";
            /*var url=comonts.getReportUrl(true,label,name,'s_rybh%3d'+rybh);
            addTab("健康体检报表",url);*/
            if(gcbh == undefined || gcbh==null || gcbh==""){
                $.messager.alert('提示','无数据打印');
            }else {
                var url=comonts.getReportUrl(true,labName,labName,'gcbh%3d'+gcbh);
                /*addTab("新收人员健康检查登记表",url);*/
                OpenWindow=window.open(url, "新收人员健康检查登记表");
                var content = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
                OpenWindow.document.write("<TITLE>新收人员健康检查登记表</TITLE>")
                OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
                OpenWindow.document.write(content)
                OpenWindow.document.write("</BODY>")
                OpenWindow.document.write("</HTML>")
                OpenWindow.document.close()
            }
        }

        //打印体表伤情报表
        var prints = function(gcbh){
            var labName="kss_sqtzd";
            /*var url=comonts.getReportUrl(true,label,name,'s_rybh%3d'+rybh);
            addTab("体表伤情报表",url);*/
            if(gcbh == undefined || gcbh==null || gcbh==""){
                $.messager.alert('提示','无数据打印');
            }else {
                var url=comonts.getReportUrl(true,labName,labName,'gcbh%3d'+gcbh);
                console.log(url);
                /*addTab("体表伤情报表",url);*/
                OpenWindow=window.open(url, "体表伤情报表");
                var content = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
                OpenWindow.document.write("<TITLE>体表伤情报表</TITLE>")
                OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
                OpenWindow.document.write(content)
                OpenWindow.document.write("</BODY>")
                OpenWindow.document.write("</HTML>")
                OpenWindow.document.close()
            }
        }
        //健康检查form提交表单（保存操作） 拒收
        var refusejkjcForm=function(){
            var url = "/kss_jkjc/firstJkjc?sfyjs=2";
            var row = $('#jkjcId').datagrid('getSelected');
            var validate=$("#dlg").form('validate');
            if (validate) {
                $('#jsbhIDU').textbox('setValue',row.jsbh);
                var data =$("#fm_jkjc").serialize();
                /* ---- 验证身高  -----*/
                var num = document.getElementById('sgfm').value;
                if(!(/^6[0-9]$|^[6-9]\d$|^1\d{2}$|^2\d{2}$|^3\d{2}$/.test(num))){ //大于60小于400
                    $.messager.alert("提示","身高输入项的最小值是 60","info");
                    return false;
                }
                /* ---- 验证身高  -----*/
                /* ---- 验证体重  -----*/
                var num = document.getElementById('tzfm').value;
                if(!(/^3[0-9]$|^[2-9]\d$|^1\d{2}$|^2\d{2}$|^9\d{2}$/.test(num))){
                    $.messager.alert("提示","体重输入项的最小值是 30","info");
                    return false;
                }
                /* ---- 验证体重  -----*/
                /* ---- 验证足长  -----*/
                var num = document.getElementById('zcfm').value;
                if(!(/^1[0-9]$|^[2-9]\d$|^1\d{2}$|^2\d{2}$|^9\d{2}$/.test(num))){
                    $.messager.alert("提示","足长输入项的最小值是 10","info");
                    return false;
                }
                /* ---- 验证足长  -----*/
                submitLoad();
                $.ajax({
                    type : "POST",  //提交方式
                    url : url,//路径
                    data : data,//数据，这里使用的是Json格式进行传输
                    success : function(result) {
                        if (result.success) {
                            $("#jkjcId").datagrid('load',{
                                "processDefinitionKey":getUrlParam('processDefinitionKey'),
                                "taskDefinitionKey":getUrlParam('taskDefinitionKey'),
                            });
                            removeLoad();
                            javascript:$('#dlg').dialog('close');
                            $.messager.alert("确定","保存成功","info");
                        }else{
                            removeLoad();
                            $.messager.alert("确定","保存失败","info");

                        }
                    },
                    complete:function(){
                        removeLoad();
                    },
                });
            }else{
                $.messager.alert("提示", '必填项不能为空！');
            }
        };
        var bindAction=function(refresh){
            $("#jkjc_save").on("click",function(){
                addjkjcForm();
            });
            $("#jkjc_jushou").on("click",function(){
                refusejkjcForm();
            });
            $("#jkjc_cancle").on("click",function(){
                $("#dlg").dialog("close");
            });
        }
        return{
            show:_show
        }
    });